<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    //允许批量赋值的字段
    protected $fillable = ['user_id','amount','address_id','order_no'];
    use HasFactory;

    public function orderDetails()
    {
        return $this->hasMany(OrderDetails::class,'order_id', 'id');
    }

    /**
     * 所属用户
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }
}
